﻿#pragma once //预处理指令 确保这个头文件只被包含（include）一次，防止重复定义。

#include "GameplayEffectTypes.h"
#include "AuraAbilityTypes.generated.h"

/*
 * 自定义效果上下文
 */
USTRUCT(BlueprintType)
struct FAuraGameplayEffectContext : public FGameplayEffectContext
{
	GENERATED_BODY()

	bool IsBlockedHit() const
	{
		return bIsBlockedHit;
	}

	void SetIsBlockedHit(const bool InbIsBlockedHit)
	{
		bIsBlockedHit = InbIsBlockedHit;
	}

	bool IsCriticalHit() const
	{
		return bIsCriticalHit;
	}

	void SetIsCriticalHit(const bool InbIsCriticalHit)
	{
		bIsCriticalHit = InbIsCriticalHit;
	}

	/** 返回用于序列化的实际结构体 */
	virtual UScriptStruct* GetScriptStruct() const override
	{
		return FAuraGameplayEffectContext::StaticStruct();
	}

	// 自定义序列化
	virtual bool NetSerialize(FArchive& Ar, UPackageMap* Map, bool& bOutSuccess) override;

	virtual FAuraGameplayEffectContext* Duplicate() const override;

protected:

	/** 是否格挡标志位 */
	UPROPERTY()
	bool bIsBlockedHit = false;

	/** 是否暴击标志位 */
	UPROPERTY()
	bool bIsCriticalHit = false;
};


/*
 * 用于定义FAuraGameplayEffectContext结构体的特性
 */
template<>
struct TStructOpsTypeTraits<FAuraGameplayEffectContext> : public TStructOpsTypeTraitsBase2<FAuraGameplayEffectContext>
{
	// 匿名枚举
	enum
	{
		WithNetSerializer = true,
		WithCopy = true
	};
};
